package com.wtwd.wtwddevice.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wtwd.wtwddevice.mapper.SetBloodPressureWarningMapper;
import com.wtwd.wtwddevice.model.entity.SetBloodPressureWarning;
import com.wtwd.wtwddevice.service.ISetBloodPressureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SetBloodPressureWarningServiceImpl extends ServiceImpl<SetBloodPressureWarningMapper, SetBloodPressureWarning> implements ISetBloodPressureService {

    @Autowired
    private SetBloodPressureWarningMapper setBloodPressureWarningMapper;

    @Override
    public int editSetBloodPressureWarning(SetBloodPressureWarning setBloodPressureWarning) {
        SetBloodPressureWarning setHeartRateWarningByDeviceId = setBloodPressureWarningMapper.selectBloodPressureWarningByDeviceId(setBloodPressureWarning.getDeviceId());
        if(setHeartRateWarningByDeviceId == null){
            int insert = setBloodPressureWarningMapper.insertSetBloodPressureWarning(setBloodPressureWarning);
        }
        return setBloodPressureWarningMapper.updateSetBloodPressureWarning(setBloodPressureWarning);
    }

    @Override
    public int editState(Long deviceId, String number, int state) {
        return setBloodPressureWarningMapper.editState(deviceId,number,state);
    }
}
